@page "{param?}"
@using FytSoa.Application.Exam
@using FytSoa.Application.Exam.Param
@using FytSoa.Application.Sys
@using FytSoa.Application.Sys.Param
@using FytSoa.Common.Utils
@inject ExamCourseService _courseService
@inject SysCodeService _codeService
@{
    ViewData["Nav"] = 3;
    ViewData["Title"] = "图文";
    var page = Request.Query["page"];
    page = string.IsNullOrEmpty(page) ? "1" : page.ToString();
    var grade = await _codeService.GetListAsync(new CodePageParam() { TypeCode = "grand", Limit = 100 });
    var subject = await _codeService.GetListAsync(new CodePageParam() { TypeCode = "subject", Limit = 100 });

    var param = RouteData.Values["param"]?.ToString();
    var paramStr = "0-0";
    long grageId = 0, subjectId = 0;
    if (!string.IsNullOrEmpty(param))
    {
        var str = param.StrToListString('-');
        grageId = long.Parse(str[0]);
        subjectId = long.Parse(str[1]);
    }

    var list = await _courseService.GetPagesAsync(new ExamCourseSearchParam()
    {
        Page = int.Parse(page),
        GradeId = grageId,
        SubjectId = subjectId,
        Type = 3,
        Limit = 12
    });

    var top = await _courseService.GetPagesAsync(new ExamCourseSearchParam()
    {
        Type = 3,
        Limit = 4,
        Attr = 3
    });
}
<div class="main_content_inner">

    <div uk-grid>
        <div class="uk-width-1-4@m uk-flex-last@m">
            <h4>最新推荐</h4>
            @{
                foreach (var item in top.Items)
                {
                    <div class="uk-card uk-card-default">
                        <div class="uk-card-media-top">
                            <a href="/graphic/single/@item.Id">
                                <img src="@item.Cover.UrlReplace()" alt="">
                            </a>
                        </div>
                        <div class="uk-card-body">
                            <a href="/graphic/single/@item.Id" style="color: #666">
                                @Html.Raw(item.Title)
                            </a>
                        </div>
                    </div>
                }
            }
        </div>

        <div class="uk-width-3-4@m">
            <div class="section-header mb-5 border-bottom uk-flex-middle">
                <div class="section-header-left">
                    <h3> 图文推荐</h3>
                </div>
                <div class="section-header-right">
                    <div class="display-as">
                        <a href="#" uk-tooltip="title: Veiw as list; pos: top-right">
                            <i class="icon-feather-grid"></i>
                        </a>
                        <a href="javascript:void(0)" class="active"
                           uk-tooltip="title: Veiw as Grid; pos: top-right">
                            <i class="icon-feather-list"></i>
                        </a>
                    </div>
                </div>
            </div>
            <div class="uk-grid-small uk-grid-divider uk-child-width-auto" uk-grid>
                <div>
                    <ul class="uk-subnav uk-subnav-pill" uk-margin>
                        <li uk-filter-control class="@(grageId == 0 ? "uk-active" : "")">
                            <a href="/graphic/0-@(subjectId)">年级</a>
                        </li>
                    </ul>
                </div>
                <div>
                    <ul class="uk-subnav uk-subnav-pill" uk-margin>
                        @{
                            foreach (var item in grade)
                            {
                                <li class="@(grageId == item.Id ? "uk-active" : "")">
                                    <a href="/graphic/@(item.Id)-@(subjectId)">@Html.Raw(item.Name)</a>
                                </li>
                            }
                        }
                    </ul>
                </div>
            </div>
            <div class="uk-grid-small uk-grid-divider uk-child-width-auto" uk-grid>
                <div>
                    <ul class="uk-subnav uk-subnav-pill" uk-margin>
                        <li uk-filter-control class="@(subjectId == 0 ? "uk-active" : "")">
                            <a href="/graphic/@(grageId)-0">学科</a>
                        </li>
                    </ul>
                </div>
                <div>
                    <ul class="uk-subnav uk-subnav-pill" uk-margin>
                        @{
                            foreach (var item in subject)
                            {
                                <li class="@(subjectId == item.Id ? "uk-active" : "")">
                                    <a href="/graphic/@(grageId)-@(item.Id)">@Html.Raw(item.Name)</a>
                                </li>
                            }
                        }
                    </ul>
                </div>
            </div>
            <div style="padding-top:20px;">
                @{
                    if (list.Items.Count == 0)
                    {
                        <div class="empty">
                            <img src="/assets/images/empty.png" alt=""/>
                            <p>暂无数据</p>
                        </div>
                    }
                    foreach (var item in list.Items)
                    {
                        <a href="/graphic/single/@item.Id" class="video-post video-post-list">
                            <!-- Blog Post Thumbnail -->
                            <div class="video-post-thumbnail">
                                <img src="@item.Cover.UrlReplace()" alt="">
                            </div>
                            <!-- Blog Post Content -->
                            <div class="video-post-content">
                                <h3>
                                    @Html.Raw(item.Title)
                                </h3>
                                <span class="video-post-user">
                                    <i class="uil-heart"></i> @item.Hits
                                </span>
                                <span class="video-post-date">
                                    <i class="uil-history"></i> @item.UpdateTime
                                </span>
                                <p style="font-size: 13px">
                                    @Html.Raw(item.Summary.CutString(150))
                                </p>
                                <!-- option menu -->
                                <span class="btn-option">
                                    <i class="icon-feather-more-vertical"></i>
                                </span>
                                <div class="dropdown-option-nav" uk-dropdown="pos: bottom-right ;mode : hover">
                                    <ul>
                                        <li>
                                            <span> <i class="uil-history"></i> 查看详情</span>
                                        </li>
                                        <li>
                                            <span> <i class="uil-bookmark"></i> 加入书签</span>
                                        </li>
                                        <li>
                                            <span> <i class="uil-share-alt"></i> 分享</span>
                                        </li>
                                    </ul>
                                </div>

                            </div>
                        </a>
                    }
                }
            </div>
            <ul class="uk-pagination my-5 uk-flex-center" uk-margin style="width:100%;">
                @Html.Raw(PageUtils.Htmls(int.Parse(page), 8, Convert.ToInt32(list.TotalPages), "/graphic/" + grageId + "-" + subjectId))
            </ul>
        </div>
    </div>

</div>